package com.oracle.lingshangejia.activity.special;

import android.app.DatePickerDialog;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.oracle.lingshangejia.Constant;
import com.oracle.lingshangejia.R;
import com.oracle.lingshangejia.adapter.special.LNRArchivesExtendableListAdapter;
import com.oracle.lingshangejia.bean.DataBean;
import com.oracle.lingshangejia.bean.User;
import com.oracle.lingshangejia.dialog.LoadingViewDialog;
import com.oracle.lingshangejia.model.OkgoNetwork;
import com.oracle.lingshangejia.utils.MyLogger;
import com.oracle.lingshangejia.utils.MyToast;
import com.oracle.lingshangejia.utils.ObserverOnNext;
import com.oracle.lingshangejia.utils.RxUtils;

import org.json.JSONObject;

import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;

//老年人中医药健康
public class LaoNianRenActivity extends AppCompatActivity {
    private ExpandableListView expandableListView;
    private LNRArchivesExtendableListAdapter archivesExtendableListAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.lnr_add_archives_activity);
        initBasic();
        expandableListView = findViewById(R.id.expend_list);
        expandableListView.setGroupIndicator(null);
        String[] archivesStr = getResources().getStringArray(R.array.lnr_archives);
        archivesExtendableListAdapter = new LNRArchivesExtendableListAdapter(archivesStr);
        expandableListView.setAdapter(archivesExtendableListAdapter);
        // 添加末尾提交按钮
        View foot = LayoutInflater.from(this).inflate(R.layout.archives_foot_submit, null);
        expandableListView.addFooterView(foot);

        expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
            @Override
            public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
                return false;
            }
        });

        expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
            @Override
            public void onGroupExpand(int groupPosition) {
                int count = expandableListView.getExpandableListAdapter().getGroupCount();
                for (int i = 0; i < count; i++) {
                    if (i != groupPosition) {
                        expandableListView.collapseGroup(i);
                    }
                }
            }
        });
        expandableListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
            @Override
            public void onGroupCollapse(int groupPosition) {
                View[] views = ((LNRArchivesExtendableListAdapter) expandableListView.getExpandableListAdapter()).getConvertViews();
                View view = views[groupPosition];
                if (view == null) {
                    return;
                }
                Map<String, String> values = null;
                switch (groupPosition) {
                    case 0:
                        values = getBasicInfoValues();
                        break;
                    case 1:
                        values = Firsttable_1(view);
                        break;
                    case 2:
                        values = Firsttable_2(view);
                        break;
                    case 3:
                        values = Firsttable_3(view);
                        break;
                    case 4:
                        values = Firsttable_4(view);
                        break;
                    case 5:
                        values = Firsttable_5(view);
                        break;


                }

            }
        });

        expandableListView.expandGroup(0);


    }


    /**
     * 检查用户名、身份证号和本人联系电话是否正确填写
     *
     * @return 数据不正确返回true，正确返回false
     */
    private boolean checkBasicInfoIsError() {
        Map<String, String> basicInforValues = getBasicInfoValues();
        String xm = (String) basicInforValues.get("xm");

        // 姓名非空验证
        if (xm == null || xm.length() == 0) {
            Toast.makeText(getApplicationContext(), "姓名必须填写", Toast.LENGTH_SHORT).show();
            return true;
        }
        return false;
    }


    /**
     * 获取基本信息数据
     */
    private Map<String, String> getBasicInfoValues() {
        View[] views = ((LNRArchivesExtendableListAdapter) expandableListView.getExpandableListAdapter()).getConvertViews();
        View view = views[0];
        Map<String, String> params = new HashMap<>();
        String username;
        String services_scoring_1;
        String services_scoring_2;
        String services_scoring_3;
        String services_scoring_4;
        String services_scoring_5;
        String services_scoring_6;
        String juminID="";
        String yishengID="";
       //username= ((EditText) view.findViewById(R.id.postpartum_42_health_examination_username)).getText().toString().trim();
        services_scoring_1= ((Spinner) view.findViewById(R.id.health_management_services_scoring_1)).getSelectedItem().toString().trim();
        services_scoring_1 = services_scoring_1.substring(0, services_scoring_1.indexOf(" "));
        services_scoring_2= ((Spinner) view.findViewById(R.id.health_management_services_scoring_2)).getSelectedItem().toString().trim();
        services_scoring_2 = services_scoring_2.substring(0, services_scoring_2.indexOf(" "));
        services_scoring_3= ((Spinner) view.findViewById(R.id.health_management_services_scoring_3)).getSelectedItem().toString().trim();
        services_scoring_3 = services_scoring_3.substring(0, services_scoring_3.indexOf(" "));
        services_scoring_4= ((Spinner) view.findViewById(R.id.health_management_services_scoring_4)).getSelectedItem().toString().trim();
        services_scoring_4 = services_scoring_4.substring(0, services_scoring_4.indexOf(" "));
        services_scoring_5= ((Spinner) view.findViewById(R.id.health_management_services_scoring_5)).getSelectedItem().toString().trim();
        services_scoring_5 = services_scoring_5.substring(0, services_scoring_5.indexOf(" "));
        services_scoring_6= ((Spinner) view.findViewById(R.id.health_management_services_scoring_6)).getSelectedItem().toString().trim();
        services_scoring_6 = services_scoring_6.substring(0, services_scoring_6.indexOf(" "));
       // juminID= ((EditText) view.findViewById(R.id.postpartum_42_health_examination_juminid)).getText().toString().trim();
      //  yishengID= ((EditText) view.findViewById(R.id.postpartum_42_health_examination_yishengid)).getText().toString().trim();
       /* params.put("jv_id",juminID);
        params.put("ysid",yishengID);*/
       // params.put("xm",username);
        params.put("lnrWt1",services_scoring_1);
        params.put("lnrWt2",services_scoring_2);
        params.put("lnrWt3",services_scoring_3);
        params.put("lnrWt4",services_scoring_4);
        params.put("lnrWt5",services_scoring_5);
        params.put("lnrWt6",services_scoring_6);
        mValues.putAll(params);
        return params;
    }

    /**
     * 第二页
     */
    private Map<String, String> Firsttable_1(View view) {
        Map<String, String> params = new HashMap<>();
        String services_scoring_7;
        String services_scoring_8;
        String services_scoring_9;
        String services_scoring_10;
        String services_scoring_11;
        String services_scoring_12;
        String services_scoring_13;

        services_scoring_7= ((Spinner) view.findViewById(R.id.health_management_services_scoring_7)).getSelectedItem().toString().trim();
        services_scoring_7 = services_scoring_7.substring(0, services_scoring_7.indexOf(" "));
        services_scoring_8= ((Spinner) view.findViewById(R.id.health_management_services_scoring_8)).getSelectedItem().toString().trim();
        services_scoring_8 = services_scoring_8.substring(0, services_scoring_8.indexOf(" "));
        services_scoring_9= ((Spinner) view.findViewById(R.id.health_management_services_scoring_9)).getSelectedItem().toString().trim();
        services_scoring_9 = services_scoring_9.substring(0, services_scoring_9.indexOf(" "));
        services_scoring_10= ((Spinner) view.findViewById(R.id.health_management_services_scoring_10)).getSelectedItem().toString().trim();
        services_scoring_10 = services_scoring_10.substring(0, services_scoring_10.indexOf(" "));
        services_scoring_11= ((Spinner) view.findViewById(R.id.health_management_services_scoring_11)).getSelectedItem().toString().trim();
        services_scoring_11 = services_scoring_11.substring(0, services_scoring_11.indexOf(" "));
        services_scoring_12= ((Spinner) view.findViewById(R.id.health_management_services_scoring_12)).getSelectedItem().toString().trim();
        services_scoring_12 = services_scoring_12.substring(0, services_scoring_12.indexOf(" "));
        services_scoring_13= ((Spinner) view.findViewById(R.id.health_management_services_scoring_13)).getSelectedItem().toString().trim();
        services_scoring_13 = services_scoring_13.substring(0, services_scoring_13.indexOf(" "));

        params.put("lnrWt7",services_scoring_7);
        params.put("lnrWt8",services_scoring_8);
        params.put("lnrWt9",services_scoring_9);
        params.put("lnrWt10",services_scoring_10);
        params.put("lnrWt11",services_scoring_11);
        params.put("lnrWt12",services_scoring_12);
        params.put("lnrWt13",services_scoring_13);
        mValues.putAll(params);
        return params;
    }

    /**
     * 第三页
     */
    private Map<String, String> Firsttable_2(View view) {
        Map<String, String> params = new HashMap<>();
        String services_scoring_14;
        String services_scoring_15;
        String services_scoring_16;
        String services_scoring_17;
        String services_scoring_18;
        String services_scoring_19;


        services_scoring_14= ((Spinner) view.findViewById(R.id.health_management_services_scoring_14)).getSelectedItem().toString().trim();
        services_scoring_14 = services_scoring_14.substring(0, services_scoring_14.indexOf(" "));
        services_scoring_15= ((Spinner) view.findViewById(R.id.health_management_services_scoring_15)).getSelectedItem().toString().trim();
        services_scoring_15 = services_scoring_15.substring(0, services_scoring_15.indexOf(" "));
        services_scoring_16= ((Spinner) view.findViewById(R.id.health_management_services_scoring_16)).getSelectedItem().toString().trim();
        services_scoring_16 = services_scoring_16.substring(0, services_scoring_16.indexOf(" "));
        services_scoring_17= ((Spinner) view.findViewById(R.id.health_management_services_scoring_17)).getSelectedItem().toString().trim();
        services_scoring_17 = services_scoring_17.substring(0, services_scoring_17.indexOf(" "));
        services_scoring_18= ((Spinner) view.findViewById(R.id.health_management_services_scoring_18)).getSelectedItem().toString().trim();
        services_scoring_18 = services_scoring_18.substring(0, services_scoring_18.indexOf(" "));
        services_scoring_19= ((Spinner) view.findViewById(R.id.health_management_services_scoring_19)).getSelectedItem().toString().trim();
        services_scoring_19 = services_scoring_19.substring(0, services_scoring_19.indexOf(" "));
        params.put("lnrWt14",services_scoring_14);
        params.put("lnrWt15",services_scoring_15);
        params.put("lnrWt16",services_scoring_16);
        params.put("lnrWt17",services_scoring_17);
        params.put("lnrWt18",services_scoring_18);
        params.put("lnrWt19",services_scoring_19);
        mValues.putAll(params);
        return params;
    }

    /**
     * 第四页
     */
    private Map<String, String> Firsttable_3(View view) {
        Map<String, String> params = new HashMap<>();
        String services_scoring_20;
        String services_scoring_21;
        String services_scoring_22;
        String services_scoring_23;
        String services_scoring_24;
        String services_scoring_25;
        String services_scoring_26;

        services_scoring_20= ((Spinner) view.findViewById(R.id.health_management_services_scoring_20)).getSelectedItem().toString().trim();
        services_scoring_20 = services_scoring_20.substring(0, services_scoring_20.indexOf(" "));
        services_scoring_21= ((Spinner) view.findViewById(R.id.health_management_services_scoring_21)).getSelectedItem().toString().trim();
        services_scoring_21 = services_scoring_21.substring(0, services_scoring_21.indexOf(" "));
        services_scoring_22= ((Spinner) view.findViewById(R.id.health_management_services_scoring_22)).getSelectedItem().toString().trim();
        services_scoring_22 = services_scoring_22.substring(0, services_scoring_22.indexOf(" "));
        services_scoring_23= ((Spinner) view.findViewById(R.id.health_management_services_scoring_23)).getSelectedItem().toString().trim();
        services_scoring_23 = services_scoring_23.substring(0, services_scoring_23.indexOf(" "));
        services_scoring_24= ((Spinner) view.findViewById(R.id.health_management_services_scoring_24)).getSelectedItem().toString().trim();
        services_scoring_24 = services_scoring_24.substring(0, services_scoring_24.indexOf(" "));
        services_scoring_25= ((Spinner) view.findViewById(R.id.health_management_services_scoring_25)).getSelectedItem().toString().trim();
        services_scoring_25 = services_scoring_25.substring(0, services_scoring_25.indexOf(" "));
        services_scoring_26= ((Spinner) view.findViewById(R.id.health_management_services_scoring_26)).getSelectedItem().toString().trim();
        services_scoring_26 = services_scoring_26.substring(0, services_scoring_26.indexOf(" "));
        params.put("lnrWt20",services_scoring_20);
        params.put("lnrWt21",services_scoring_21);
        params.put("lnrWt22",services_scoring_22);
        params.put("lnrWt23",services_scoring_23);
        params.put("lnrWt24",services_scoring_24);
        params.put("lnrWt25",services_scoring_25);
        params.put("lnrWt26",services_scoring_26);
        mValues.putAll(params);
        return params;
    }
    /**
     * 第五页
     */
    private Map<String, String> Firsttable_4(View view) {
        Map<String, String> params = new HashMap<>();
        String services_scoring_27;
        String services_scoring_28;
        String services_scoring_29;
        String services_scoring_30;
        String services_scoring_31;
        String services_scoring_32;
        String services_scoring_33;

        services_scoring_27= ((Spinner) view.findViewById(R.id.health_management_services_scoring_27)).getSelectedItem().toString().trim();
        services_scoring_27 = services_scoring_27.substring(0, services_scoring_27.indexOf(" "));
        services_scoring_28= ((Spinner) view.findViewById(R.id.health_management_services_scoring_28)).getSelectedItem().toString().trim();
        services_scoring_28 = services_scoring_28.substring(0, services_scoring_28.indexOf(" "));
        services_scoring_29= ((Spinner) view.findViewById(R.id.health_management_services_scoring_29)).getSelectedItem().toString().trim();
        services_scoring_29 = services_scoring_29.substring(0, services_scoring_29.indexOf(" "));
        services_scoring_30= ((Spinner) view.findViewById(R.id.health_management_services_scoring_30)).getSelectedItem().toString().trim();
        services_scoring_30 = services_scoring_30.substring(0, services_scoring_30.indexOf(" "));
        services_scoring_31= ((Spinner) view.findViewById(R.id.health_management_services_scoring_31)).getSelectedItem().toString().trim();
        services_scoring_31 = services_scoring_31.substring(0, services_scoring_31.indexOf(" "));
        services_scoring_32= ((Spinner) view.findViewById(R.id.health_management_services_scoring_32)).getSelectedItem().toString().trim();
        services_scoring_32 = services_scoring_32.substring(0, services_scoring_32.indexOf(" "));
        services_scoring_33= ((Spinner) view.findViewById(R.id.health_management_services_scoring_33)).getSelectedItem().toString().trim();
        services_scoring_33 = services_scoring_33.substring(0, services_scoring_33.indexOf(" "));

        params.put("lnrWt27",services_scoring_27);
        params.put("lnrWt28",services_scoring_28);
        params.put("lnrWt29",services_scoring_29);
        params.put("lnrWt30",services_scoring_30);
        params.put("lnrWt31",services_scoring_31);
        params.put("lnrWt32",services_scoring_32);
        params.put("lnrWt33",services_scoring_33);
        mValues.putAll(params);
        return params;
    }
    /**
     * 第6页  气虚质
     */
    private Map<String, String> Firsttable_5(View view) {
        Map<String, String> params = new HashMap<>();
        // 原因
        String guidance= "";
        //机构及科室
        String guidance_other = "";
        String tizhiqingkuang="";
        String tizhibianshi="";
        String NextFollowupDate = "";//下次随访日期
        View[] payViews = getViews(view.findViewById(R.id.qi_deficiency_constitution_health_guidance_1));
        tizhiqingkuang = ((Spinner) view.findViewById(R.id.qi_deficiency_constitution_gender)).getSelectedItem().toString().trim();
        if (view != null) {
            RadioButton class1 = view.findViewById(R.id.qi_deficiency_constitution_jiben);
            RadioButton class2 = view.findViewById(R.id.qi_deficiency_constitution_shi);
            RadioButton class3 = view.findViewById(R.id.qi_deficiency_constitution_qingxiangshi);


            if (class1.isChecked()) {
                String s = class1.getText().toString().trim();
                s = s.substring(0, s.indexOf(" "));
                tizhibianshi  = s;
            } else if(class2.isChecked()){
                String s = class2.getText().toString().trim();
                if (s.length() > 0)
                    s = s.substring(0, s.indexOf(" "));
                tizhibianshi  = s;
            }else {
                String s = class3.getText().toString().trim();
                if (s.length() > 0)
                    s = s.substring(0, s.indexOf(" "));
                tizhibianshi  = s;
            }
            //classificationText = ((EditText) view .findViewById(R.id.a_postpartum_housecall_classification_abnormalities_text)).getText().toString().trim();
        }
        View[] symptom1Views = getViews(view.findViewById(R.id.hypertension_symptom1));
        for (int i = 0; i < symptom1Views.length; i++) {
            if (symptom1Views[i] instanceof CheckBox) {
                CheckBox cb = (CheckBox) symptom1Views[i];
                if (cb.isChecked()) {
                    String s = cb.getText().toString().trim();
                    s = s.substring(0, s.indexOf(" "));
                    guidance += s;
                    guidance += ",";
                }
            }
        }

       /* for (int i = 0; i < payViews.length; i++) {
            if (payViews[i] instanceof CheckBox) {
                CheckBox cb = (CheckBox) payViews[i];
                if (cb.isChecked()) {
                    String s = cb.getText().toString().trim();
                    s = s.substring(0, s.indexOf(" "));
                    guidance += s;
                    guidance += ",";
                }
            }
        }*/
        if (guidance.length() != 0) {
            guidance = guidance.substring(0, guidance.length() - 1);
        }
       MyLogger.i(guidance+"中医指导");
        NextFollowupDate = ((TextView) view.findViewById(R.id.diabetic_records_1_NextFollowupDate)).getText().toString().trim();
        guidance_other = ((EditText) view.findViewById(R.id.qi_deficiency_constitution_health_guidance_6_text)).getText().toString().trim();
        tizhiqingkuang = tizhiqingkuang.substring(0, tizhiqingkuang.indexOf(" "));
        params.put("lnrTzlx", tizhiqingkuang);  //体质辨识类型
        params.put("lnrZyybjzdQt", guidance_other);//中医药保健指导_其他
        params.put("lnrZyybjzd", guidance);////中医药保健指导
        params.put("lnrTzbs", tizhibianshi); //体质辨识
        params.put("scsfsj", NextFollowupDate);//日期
        JSONObject jsonObject = new JSONObject(params) ;
        MyLogger.i(jsonObject.toString());
        mValues.putAll(params);
        return params;
    }

    /**
     * 下次随访日期
     */

    public void onXiacisuifangriqiClick1(final View v) {
        calendar = Calendar.getInstance();
        dialog = new DatePickerDialog(LaoNianRenActivity.this,
                new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year,
                                          int monthOfYear, int dayOfMonth) {
                        TextView tv = (TextView) v;
                        String month;
                        String day;
                        if (monthOfYear <9){
                            month = "0"+(monthOfYear+1);
                        }else {
                            month = ""+(monthOfYear+1);
                        }
                        if (dayOfMonth <10){
                            day = "0"+dayOfMonth;
                        }else {
                            day = dayOfMonth + "";
                        }
                        tv.setText(year + "-" + month  + "-" + day);
                    }
                }, calendar.get(Calendar.YEAR), calendar
                .get(Calendar.MONTH), calendar
                .get(Calendar.DAY_OF_MONTH));
        dialog.show();
    }





    /**
     * Toolbar的事件---返回
     */
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }
    private Calendar calendar;
    private DatePickerDialog dialog;
    /*时间*/
    public void onTimeViewClick(final View v) {
        calendar = Calendar.getInstance();
        dialog = new DatePickerDialog(LaoNianRenActivity.this,
                new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year,
                                          int monthOfYear, int dayOfMonth) {
                        TextView tv = (TextView) v;
                        tv.setText(year + "-" + (monthOfYear < 10 ? ("0" + monthOfYear) : monthOfYear) + "-"
                                + (dayOfMonth < 10 ? ("0" + dayOfMonth) : dayOfMonth));
                    }
                }, calendar.get(Calendar.YEAR), calendar
                .get(Calendar.MONTH), calendar
                .get(Calendar.DAY_OF_MONTH));
        dialog.show();
    }
    /*气虚质*/
    public void onQiDeficiencyConstitutionClick(View view) {
        CheckBox cb = (CheckBox) view;
        EditText et = findViewById(R.id.qi_deficiency_constitution_health_guidance_6_text);
        if (cb.isChecked()) {
            et.setEnabled(true);
            et.setFocusable(true);
            et.setFocusableInTouchMode(true);
            et.requestFocus();
        } else {
            et.setText("");
            et.setEnabled(false);
        }
    }

    /**
     * 获取子视图
     */
    private View[] views;

    private View[] getViews(View view) {
        views = new View[0];
        parseView(view);
        return views;
    }

    private void parseView(View view) {
        if (view instanceof ViewGroup) {
            ViewGroup vg = (ViewGroup) view;
            for (int i = 0; i < vg.getChildCount(); i++) {
                View v = vg.getChildAt(i);
                parseView(v);
            }
        } else {
            views = Arrays.copyOf(views, views.length + 1);
            views[views.length - 1] = view;
        }
    }




    /**
     * 提交数据
     */
    public void onClickSubmit(View view) {
        showLoading();
        int count = expandableListView.getExpandableListAdapter().getGroupCount();
        for (int i = 0; i < count; i++) {
            expandableListView.collapseGroup(i);
        }
        Observable.create(new ObservableOnSubscribe<DataBean>() {
            @Override
            public void subscribe(ObservableEmitter<DataBean> emitter) throws Exception {
                JSONObject jsonObject = new JSONObject(mValues);
                MyLogger.i(jsonObject.toString());
                String json = OkgoNetwork.post(url,jsonObject.toString());
                MyLogger.i(json);
                Gson gson = new Gson();
                emitter.onNext(gson.fromJson(json, DataBean.class));

            }
        }).compose(RxUtils.io_main()).subscribe(new ObserverOnNext<DataBean>() {
            @Override
            public void onNext(DataBean dataBean) {
                if (dataBean.getCode()==0){
                    MyToast.show("提交成功");
                    finish();
                }else {
                    MyToast.show(dataBean.getMsg());
                }
                dismissLoading();

            }
        });

    }


    //新
    private Map<Object,Object> mValues = new HashMap<>();
    private  String url = Constant.baseurl+"online/zxdalnr/save";
    private LoadingViewDialog mLoadingView;
    //整合专项  基础 修改
    private void initBasic(){
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        Toolbar toolbar = (Toolbar)findViewById(com.oracle.children.R.id.toolbar);
        toolbar.setTitle("");
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        mValues.put("token", User.getToken());
        mValues.put("jmId",getIntent().getIntExtra("jmid", 0) );
        mValues.put("userId", User.getUserId());//社区医生id;
        mValues.put("mark", 1);
        //随访id
        int id = getIntent().getIntExtra("id", 0);
        if (id !=0){
            mValues.put("sfjlId", id);
            mValues.put("id", id);
        }
    }



    public void showLoading(){
        mLoadingView = new LoadingViewDialog();
        mLoadingView.show(getSupportFragmentManager(),"" );
    }
    public void dismissLoading(){
        if (mLoadingView != null){
            mLoadingView.dismiss();
        }

    }
}
